package bishi.wangyi;

import java.util.Arrays;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.Stream;

/**
 * @Classname Main2
 * @Description TODO
 * @Date 2021/9/19 15:47
 * @Created by ASUS
 */
public class Main2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        List<Integer> nums = Arrays.stream(scanner.nextLine().split(" ")).map(Integer::parseInt).collect(Collectors.toList());
        scanner.close();
        int a = nums.get(0), b = nums.get(1);
        if (b % a != 0) System.out.println(-1);
        else System.out.println(divide(b / a) + 1);
    }

    static boolean prime(int n) {
        for (int i = 2; i <= Math.sqrt(n); i++) if (n % i == 0) return false;
        return true;
    }

    static int divide(int m) {
        if (m == 1) return 0;
        else if (prime(m)) return 1;
        else {
            for (int i = 2; i <= Math.sqrt(m); i++) if (m % i == 0) {
                System.out.println(i+ " " + m / i);
                return divide(i) + divide(m / i);
            }
        }
        return 0;
    }
}
